package hwf.db.conn;

import java.sql.Connection;
import java.sql.DriverManager;

public class GetConn {
 public GetConn(){}
 public  Connection getConnection(){
	 String strDriver = "oracle.jdbc.driver.OracleDriver";//驱动程序
     String strURL = "jdbc:oracle:thin:@133.160.76.193:1521:shcm";//数据库服务器地址及数据库名
 	
     Connection con = null;

     try{
       Class.forName(strDriver).newInstance();//显示的加载驱动程序类
     }catch(Exception ex){
       //在这儿进行错误处理
       System.out.println("Driver not found!");
     }

     try{
       con = DriverManager.getConnection(strURL,"data","data");
       System.out.println("当前连接的数据库为：" + strURL + "/x/x");
     }catch(Exception e){
        //con.rollback();
        e.printStackTrace();
     }

     return con;
 }
 public  Connection getConn(){
	 String strDriver = "sun.jdbc.odbc.JdbcOdbcDriver";//驱动程序  
     String strURL = "jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=H:\\java\\email.mdb";//数据库服务器地址及数据库名
     Connection con = null;

     try{
       Class.forName(strDriver).newInstance();//显示的加载驱动程序类
     }catch(Exception ex){
       //在这儿进行错误处理
       System.out.println("Driver not found!");
     }

     try{
       con = DriverManager.getConnection(strURL,"","");
       System.out.println("当前连接的数据库为：" + strURL + "/x/x");
     }catch(Exception e){
        //con.rollback();
        e.printStackTrace();
     }
     return con;
 }

}
